import request from '@/utils/request'

/**
 * 获取分类列表
 */
export function getCategoriesApi(params) {
  return request({
    url: '/categories',
    method: 'get',
    params
  })
}
/**
 * 获取分类数量
 */
export function getCategoriesCounApi(params) {
  return request({
    url: '/categories/count',
    method: 'get',
    params
  })
}
/**
 * 根据id获取分类
 */
export function getCategoryApi(id) {
  return request({
    url: `/categories/${id}`,
    method: 'get'
  })
}

/**
 * 删除
 */
export function delCategoriesApi(id) {
  return request({
    url: `/categories/${id}`,
    method: 'delete'
  })
}
/**
 * 编辑
 */
export function editCategoriesApi(data) {
  return request({
    url: `/categories/${data.id}`,
    method: 'put',
    data
  })
}
/**
 * 新增
 */
export function addCategoriesApi(data) {
  return request({
    url: '/categories',
    method: 'post',
    data
  })
}
